# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=sequoia-chameleon-gnupg
pkgver=0.2.0
pkgrel=2
pkgdesc="A re-implementation and drop-in replacement of gpg and gpgv"
arch=(loong64 x86_64)
url="https://gitlab.com/sequoia-pgp/sequoia-chameleon-gnupg"
license=(GPL3)
groups=(sequoia)
depends=(
  gcc-libs
  glibc
  gmp
)
makedepends=(
  bzip2
  cargo
  clang
  nettle
)
source=($url/-/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('1028e58c5e2a51599fed765fec23bbbd608780c9ec6f78ddc197bb5cbce4cc7dc432d736dcc310c1cd16badfc3b38248ac596d58fa271dda4602cee10aff4e09')
b2sums=('6c371b635512c5f0dce7127c3aba4fc0a0755613f9578cd9c6ed5dc8da499c9bd6140156683c2b876bacd50ab26156357d72f184fae4169ddcb24dfaffcf512d')

prepare() {
  cd $pkgname-v$pkgver
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $pkgname-v$pkgver
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

# checks broken: https://gitlab.com/sequoia-pgp/sequoia-chameleon-gnupg/-/issues/8
# check() {
#   cd $pkgname-v$pkgver
#   export RUSTUP_TOOLCHAIN=stable
#   cargo test --frozen --all-features
# }

package() {
  depends+=(
    bzip2 libbz2.so
    nettle libnettle.so libhogweed.so
  )
  cd $pkgname-v$pkgver
  install -vDm 755 target/release/gpg{,v}-sq -t "$pkgdir/usr/bin/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
